<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Paypal extends MX_Controller {

	public function __construct() {
		parent::__construct();
		$this->load->model(array('admin_commoncall','admin_settings_model','admin_review_model','admin_payment_gateway_model'));

		$this->admin_commoncall->check_admin_login();
		$this->template->set_theme('admin');
		$this->template->set_layout('default');
		

	}

	function index()
	{
		
	$paypal = $this->admin_payment_gateway_model->get_payment_gateway(2);
          if ($paypal) {
            $data['paypal_user'] = $paypal->user_id;
            $data['paypal_password'] = $paypal->password;
            $data['paypal_status'] = $paypal->status;
        }
		
		$this->template->title('Welcome', 'Ypage.com')
		->set_partial('nav_bar','layouts/nav_bar')
		->set_partial('side_menu','layouts/side_menu')
		//->set_partial('footer', 'footer/footer')
		->build('payment_gateway/paypal',$data);
	}
	function paypal_update() {
		$paypal_user_id = $_POST['paypal_user_id'];
		$paypal_password = $_POST['paypal_password'];
		$paypal_status = $_POST['paypal_status'];
		$paypal_data = array(
				'user_id' => $paypal_user_id,
				'password' => $paypal_password,
				'status' => $paypal_status
		);
		//if ($this->config->item('mode') != 'DEMO')
			$this->db->update('payment_gateway', $paypal_data);
			$this->session->set_flashdata('message', 'Paypal Updated Sucessfully..........');
			redirect('secure/payment_gateway/paypal');
	}
	function authorized_dot_net(){
	$paypal = $this->admin_payment_gateway_model->get_payment_gateway(1);
        if ($paypal) {
            $data['auth_user'] = $paypal->user_id;
            $data['auth_api'] = $paypal->api_id;
            $data['auth_transaction_key'] = $paypal->transaction_key;
            $data['auth_status'] = $paypal->status;
        }
		$this->template->title('Welcome', 'Ypage.com')
		->set_partial('nav_bar','layouts/nav_bar')
		->set_partial('side_menu','layouts/side_menu')
		//->set_partial('footer', 'footer/footer')
		->build('payment_gateway/admin_authorized_dotnet',$data);
	}
	
	function autho_update() {
		
		$auth_user_id = $_POST['auth_user_id'];
		$auth_api = $_POST['auth_Api_id'];
		$auth_transaction = $_POST['auth_transaction_key'];
		$auth_status = $_POST['auth_status'];
		$auth_data = array(
				'user_id' => $auth_user_id,
				'api_id' => $auth_api,
				'transaction_key'=>$auth_transaction,
				'status' => $auth_status
		);
		//if ($this->config->item('mode') != 'DEMO')
		
		$this->db->update('payment_gateway', $auth_data);
		$this->session->set_flashdata('message', 'Authorized dotnet Updated Sucessfully..........');
		redirect('secure/payment_gateway/paypal/authorized_dot_net');
	}
	

}



